package com.taihe.config;

import com.mchange.util.impl.HexAsciiMD5PropertiesPasswordManager;
import com.taihe.domain.User;
import com.taihe.shiro.UserRealm;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.realm.Realm;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Created by zwt on 2018/7/24.
 * shiro配置文件的配置类
 */
@Configuration
public class MyShiroConfig {

   /* *//**
     * 自定义realm
     * @return
     *//*
    @Bean
    public UserRealm userRealm(){
        UserRealm userRealm = new UserRealm();
        return userRealm;
    }


    *//**
     * 安全管理器
     * @return
     *//*
    @Bean
    public SecurityManager securityManager() {
        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
        //加载realm
        securityManager.setRealm(userRealm());
        return securityManager;
    }


    *//**
     * 过滤器链
     * @param securityManager
     * @return
     *//*
    @Bean
    public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager){
        ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
        //注入securityManager
        shiroFilterFactoryBean.setSecurityManager(securityManager);
        //注入过滤器链
        //拦截器.
        Map<String,String> filterChainDefinitionMap = new LinkedHashMap<String,String>();
        filterChainDefinitionMap.put("/logout", "logout");
        filterChainDefinitionMap.put("*//**", "authc");
        filterChainDefinitionMap.put("/login/toLogin", "anon");
        filterChainDefinitionMap.put("/plugins*//**", "anon");
        shiroFilterFactoryBean.setLoginUrl("/login");
        // 登录成功后要跳转的链接
        shiroFilterFactoryBean.setSuccessUrl("/index");
        //未授权界面;  错误页面 403.html
        shiroFilterFactoryBean.setUnauthorizedUrl("/403");
        shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
        return shiroFilterFactoryBean;
    }
*/








}
